package com.admin.library.controller;

import com.admin.library.common.base.BaseController;
import com.admin.library.common.base.R;
import com.admin.library.domain.entity.Publisher;
import com.admin.library.domain.entity.Reader;
import com.admin.library.service.PublisherService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Lii
 * @create 2022-05-27 11:18
 */
@RestController
@RequestMapping("/publisher")
public class PublisherController extends BaseController {

    @Resource
    private PublisherService publisherService;

    /**
     *
     * @param page
     * @param publisher
     * @return
     */
    @GetMapping("/list")
    public R selectAll(Page<Publisher> page, Publisher publisher) {
        return result(this.publisherService.page(page, publisher));
    }


    /**
     *
     * @param publisher
     * @return
     */
    @PostMapping("/add")
    public R addPublisher(@RequestBody Publisher publisher) {
        return result(publisherService.save(publisher));
    }

    /**
     *
     * @param publisher
     * @return
     */
    @PostMapping("/update")
    public R updatePublisher(@RequestBody Publisher publisher) {
        return result(publisherService.updateById(publisher));
    }

    /**
     *
     * @param ids
     * @return
     */
    @GetMapping("/delete")
    public R deletePublisher(@RequestParam List<String> ids) {
        return result(publisherService.removeByIds(ids));
    }


}
